package com.ibeeking.found.log.rest.controller.v1;

import com.ibeeking.found.log.rest.service.ILogGroupService;
import com.ibeeking.found.log.service.common.param.LogGroupParam;
import com.ibeeking.found.log.service.common.query.LogGroupPageQuery;
import com.ibeeking.found.log.service.common.query.LogGroupQuery;
import com.ibeeking.found.log.service.common.vo.LogGroupVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName LogGroupController控制器
 * @Description
 * @Author ibeeking
 * @Date 2021-02-25 17:55
 **/
@RestController
@RequestMapping("/b/logGroup/v1")
public class LogGroupController {

    @Resource
    private ILogGroupService logGroupServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "日志分组列表")
    @PostMapping(value = "/list")
    public List<LogGroupVO> list(@RequestBody LogGroupQuery logGroupQuery) {
        return logGroupServiceImpl.list(logGroupQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "日志分组分页列表")
    @PostMapping(value = "/pageList")
    public Page<LogGroupVO> pageList(@RequestBody LogGroupPageQuery logGroupPageQuery) {
        return logGroupServiceImpl.pageList(logGroupPageQuery);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "日志分组添加")
    @PostMapping(value = "/add")
    public Boolean add(@RequestBody @Validated(BaseValidationGroup.Insert.class) LogGroupParam logGroupParam) {
        return logGroupServiceImpl.add(logGroupParam);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "日志分组修改")
    @PostMapping(value = "/modify")
    public Boolean modify(@RequestBody @Validated(BaseValidationGroup.Update.class) LogGroupParam logGroupParam) {
        return logGroupServiceImpl.modify(logGroupParam);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "日志分组查询")
    @GetMapping(value = "/view/{id}")
    public LogGroupVO view(@PathVariable("id") Long id) {
        return logGroupServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "日志分组删除")
    @GetMapping(value = "/del/{id}")
    public Boolean del(@PathVariable("id") Long id) {
        return logGroupServiceImpl.del(id);
    }
}